//attrobj {"width":300,"height":500,opacity:100}
function startMove(domobj, attrobj, fn) {
  clearInterval(domobj.timer);
  domobj.timer = setInterval(function () {
    //假设都达到了目标值
    let flag = true;
    for (let attr in attrobj) {
      let iCur;
      if (attr == "opacity") {
        iCur = parseInt(getStyle(domobj, "opacity") * 100);
      } else {
        iCur = parseInt(getStyle(domobj, attr)); //取指定样式属性的当前值
      }
      let iTar = attrobj[attr]; //目标值
      let iSpeed = (iTar - iCur) / 8;
      iSpeed = iSpeed > 0 ? Math.ceil(iSpeed) : Math.floor(iSpeed);
      if (attr == "opacity") {
        domobj.style[attr] = (iCur + iSpeed) / 100;
      } else {
        domobj.style[attr] = iCur + iSpeed + "px";
      }

      if (iCur != iTar) { //如果当前值和目标值不等，假设不成立
        flag = false;
      }
    }
    if (flag) { //所有都达到目标值了，假设成立
      clearInterval(domobj.timer);
      if (fn) {
        fn();
      }
    }

  }, 20)
}

function getStyle(domobj, attr) {
  if (window.getComputedStyle) {
    return getComputedStyle(domobj, null)[attr];
  }
  return domobj.currentStyle[attr];
}